import time

from selenium.webdriver.remote.webdriver import WebDriver
from selenium.webdriver.remote.webelement import WebElement
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as ec

TIMEOUT=8

class Page():
    def __init__(self,driver: WebDriver):
        self.driver=driver

    def load_url(self,url):
        self.driver.get(url)

    def wait_click(self,loc,timeout=None)->WebElement:
        timeout=TIMEOUT if timeout is None else timeout
        wait=WebDriverWait(self.driver,timeout=timeout)
        return wait.until(ec.element_to_be_clickable(loc))

    def click(self,loc):
        c=self.wait_click(loc)
        c.click()

    def fill(self,loc,info):
        a=self.wait_click(loc)
        a.send_keys(info)
    def gettext(self,loc):
        b=self.wait_click(loc).text
        return b

    def sleep(self,times):
        time.sleep(times)







